package com.gudong.performance.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.Calendar;

/**
 * 类功能描述：
 *
 * @author：刘富国
 * @createTime：2019-04-05 18:40
 */
@Controller
public class IndexController {


    @RequestMapping("index")
    public String index(HttpServletRequest request, ModelMap modelMap) {

        modelMap.addAttribute("time", request.getParameter("time"));
        if (StringUtils.isEmpty(request.getParameter("time"))) {
            Calendar calendar = Calendar.getInstance();
            modelMap.addAttribute("time", calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1 > 10 ? ""+calendar.get(Calendar.MONTH) + 1 : "0" + (calendar.get(Calendar.MONTH) + 1)));
        }

        return "index";
    }
}
